package iopera;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-07-13
 * Time: 14:23
 */
public class FindIOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("查阅图书");
        System.out.println("请输入要查阅的书籍：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();

        int currentSized = bookList.getUsedSized();
        for (int i = 0; i < currentSized; i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)){
                System.out.println("找到了");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到");
    }
}
